<template>
  <div>
    <el-card>
      <el-row>
        <el-form ref="form" :model="formData" label-width="80px">
          <el-row>
            <el-col :span="18">
              <el-form-item label="监督机构" prop="orgId" style="margin-left: 50px;margin-top: 20px">
                <el-select v-model="formData.orgId" clearable style="margin-left: 20px;" placeholder="请选择">
                  <el-option
                    v-for="item in orglist"
                    :key="item.id"
                    :label="item.orgName"
                    :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6" style="margin-top: 20px">
              <el-button type="success" @click="quire">检索</el-button>
            </el-col>
          </el-row>
        </el-form>
      </el-row>
      <el-divider></el-divider>
      <el-row>
        <el-col :span="18">
          <span> <i class="el-icon-basketball"></i> </span>
        </el-col>
        <el-col :span="3">
          <span>人数</span>
        </el-col>
        <el-col :span="3">
          <span>百分比</span>
        </el-col>
      </el-row>
      <el-divider></el-divider>
      <el-row>
        <el-col :span="18">
          <span>监督总人数</span>
        </el-col>
        <el-col :span="3"><span>{{form.totalspe}}</span></el-col>
        <el-col :span="3"><span>{{Math.round(form.totalspe*100/form.num)+'%'}}</span></el-col>
      </el-row>
      <el-divider></el-divider>
      <el-row>
        <el-col :span="8">
          <span>性别构成</span>
        </el-col>
        <el-col :span="10">
          <el-row><el-col :span="10">男</el-col></el-row>
          <el-row><el-col :span="10">女</el-col></el-row>
        </el-col>
        <el-col :span="3">
          <el-row>
            <el-col :span="3">{{form.men}}</el-col>
          </el-row>
          <el-row>
            <el-col :span="3">{{form.women}}</el-col>
          </el-row>
        </el-col>
        <el-col :span="3">
          <el-row>
            <el-col :span="3"><span>{{Math.round(form.men*100/form.totalgender)+'%'}}</span></el-col>
          </el-row>
          <el-row>
            <el-col :span="3"><span>{{Math.round(form.women*100/(form.totalgender))+'%'}}</span></el-col>
          </el-row>
        </el-col>
      </el-row>
      <el-divider></el-divider>
      <el-row>
        <el-col :span="8">
          <span>年龄构成</span>
        </el-col>
        <el-col :span="10">
          <el-row><el-col :span="10">35岁及以下</el-col></el-row>
          <el-row><el-col :span="10">36及40岁</el-col></el-row>
          <el-row><el-col :span="10">41岁及45</el-col></el-row>
          <el-row><el-col :span="10">46岁及50</el-col></el-row>
          <el-row><el-col :span="10">51岁及54</el-col></el-row>
          <el-row><el-col :span="10">55岁以上</el-col></el-row>
        </el-col>
        <el-col :span="3">
          <el-row><el-col :span="3"><span>{{form.agea}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.ageb}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.agec}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.aged}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.agee}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.agef}}</span></el-col></el-row>
        </el-col>
        <el-col :span="3">
          <el-row><el-col :span="3"><span>{{Math.round(form.agea*100/form.totalage)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.ageb*100/form.totalage)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.agec*100/form.totalage)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.aged*100/form.totalage)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.agee*100/form.totalage)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.agef*100/form.totalage)+'%'}}</span></el-col></el-row>
        </el-col>
      </el-row>
      <el-divider></el-divider>
      <el-row>
        <el-col :span="8">
          <span>学历构成</span>
        </el-col>
        <el-col :span="10">
          <el-row><el-col :span="10">博士</el-col></el-row>
          <el-row><el-col :span="10">研究生</el-col></el-row>
          <el-row><el-col :span="10">大学本科</el-col></el-row>
          <el-row><el-col :span="10">大学专科</el-col></el-row>
          <el-row><el-col :span="10">中专</el-col></el-row>
          <el-row><el-col :span="10">其他(高中，初中，无学历)</el-col></el-row>
        </el-col>
        <el-col :span="3">
          <el-row><el-col :span="3"><span>{{form.doctor}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.Master}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.undergraduate}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.college}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.special}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.st}}</span></el-col></el-row>
        </el-col>
        <el-col :span="3">
          <el-row><el-col :span="3"><span>{{Math.round(form.doctor*100/form.totaledu)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.Master*100/form.totaledu)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.undergraduate*100/form.totaledu)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.college*100/form.totaledu)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.special*100/form.totaledu)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.st*100/form.totaledu)+'%'}}</span></el-col></el-row>
        </el-col>
      </el-row>
      <el-divider></el-divider>
      <el-row>
        <el-col :span="8">
          <span>职称构成</span>
        </el-col>
        <el-col :span="10">
          <el-row><el-col :span="10">正高级</el-col></el-row>
          <el-row><el-col :span="10">副高级</el-col></el-row>
          <el-row><el-col :span="10">中级</el-col></el-row>
          <el-row><el-col :span="10">初级</el-col></el-row>
          <el-row><el-col :span="10">无职称</el-col></el-row>
        </el-col>
        <el-col :span="3">
          <el-row><el-col :span="3"><span>{{form.a}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.b}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.c}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.d}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.e}}</span></el-col></el-row>
        </el-col>
        <el-col :span="3">
          <el-row><el-col :span="3"><span>{{Math.round(form.a*100/form.totaltitle)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.b*100/form.totaltitle)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.c*100/form.totaltitle)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.d*100/form.totaltitle)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.e*100/form.totaltitle)+'%'}}</span></el-col></el-row>
        </el-col>
      </el-row>
      <el-divider></el-divider>
      <el-row>
        <el-col :span="8">
          <span>所学专业构成</span>
        </el-col>
        <el-col :span="10">
          <el-row><el-col :span="10">公共卫生</el-col></el-row>
          <el-row><el-col :span="10">医药</el-col></el-row>
          <el-row><el-col :span="10">法律</el-col></el-row>
          <el-row><el-col :span="10">工程</el-col></el-row>
          <el-row><el-col :span="10">其他专业</el-col></el-row>
          <el-row><el-col :span="10">无专业</el-col></el-row>
          <el-row><el-col :span="10">不详</el-col></el-row>
        </el-col>
        <el-col :span="3">
          <el-row><el-col :span="3"><span>{{form.ja}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.jb}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.jc}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.jd}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.je}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.jf}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{form.jg}}</span></el-col></el-row>
        </el-col>
        <el-col :span="3">
          <el-row><el-col :span="3"><span>{{Math.round(form.ja*100/form.totalspe)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.jb*100/form.totalspe)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.jc*100/form.totalspe)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.jd*100/form.totalspe)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.je*100/form.totalspe)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.jf*100/form.totalspe)+'%'}}</span></el-col></el-row>
          <el-row><el-col :span="3"><span>{{Math.round(form.jg*100/form.totalspe)+'%'}}</span></el-col></el-row>
        </el-col>
      </el-row>
    </el-card>

  </div>
</template>

<script>
  import {post} from "@/utils/api";

  export default {
    data() {
      return {
        list:[],
        formData:{},
        personlist:[],
        orglist:[],
        form:{}
      }
    },
    async created() {
      let res = await post("org/getallorg")
      this.orglist = res
      let res1 = await post("person/getallorgid")
      this.ids = res1.map((item,index)=>{
        return item.orgId
      })
      // console.log(this.ids)
      this.getbypage()
    },
    methods: {
      async getbypage() {
        let res1 = await post("leader/get7", {id: this.ids})
        let res2 = await post("leader/get8", {id: this.ids})
        let res3 = await post("leader/get9", {id: this.ids})
        let res4 = await post("leader/get10", {id: this.ids})
        let res5 = await post("leader/get11", {id: this.ids})
        let res6 = await post("leader/get12")
        this.personlist = res1.map((item,index)=>{
          return {...item,...res2[index],...res3[index],...res4[index],...res5[index],...res6[index]}
        })
        this.form = this.personlist[0]
        console.log(this.form);
      },
      async quire() {
        console.log(this.formData.orgId)
        // this.ids=[]
        this.ids = this.formData.orgId
        if(this.formData.orgId == undefined){
          this.getbypage()
        }else{
          let res1 = await post("leader/get7", {id: this.ids})
          let res2 = await post("leader/get8", {id: this.ids})
          let res3 = await post("leader/get9", {id: this.ids})
          let res4 = await post("leader/get10", {id: this.ids})
          let res5 = await post("leader/get11", {id: this.ids})
          let res6 = await post("leader/get12")
          this.personlist = res1.map((item, index) => {
            return {...item, ...res2[index], ...res3[index], ...res4[index], ...res5[index],...res6[index]}
          })
          this.form = this.personlist[0]
          console.log(this.form);
        }

      },

    }
  }
</script>

<style>
  .el-row{
    margin-top: 10px;
  }
</style>

